<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./面向对象封装/http.js"></script>
    <style>
        html,body{
            height:100%;
            width: 100%;
        }
        *{
            padding: 0;
            margin: 0;
        }
        body{
            text-align: center;
        }
        p{
            margin:20px 0;
        }
    </style>
</head>
<body>
    <h1>注册页</h1>
    <p>账号:<input type="text" placeholder="请输入账号" class="account"></p>
    <p>密码:<input type="password" placeholder="请输入账号" class="pwd"></p>
    <p><button>立即注册</button></p>
    <script>
        let btn=document.querySelector("button");
        let acc=document.querySelector(".account");
        let pwd=document.querySelector(".pwd");
        btn.addEventListener("click",function(){
            let obj={
                account:`${acc.value}`,
                password:`${pwd.value}`
            }
            http.ajax({
                type:"post",
                url:"http://139.9.177.51:8099/users/add",
                data:obj,
                sucess:function(res){
                    if(res.status==0){
                        alert("注册成功");
                        location.href="login.html";
                    }
                    else{
                        alert("注册失败,请重新输入");
                    }
                }
            })
        })
        
    </script>
</body>
</html>